package com.six.epidemic.report.controller

import com.six.library.model.ResultData
import com.six.library.model.ResultInfo
import com.six.library.utils.Constant
import org.springframework.web.bind.annotation.*
import org.springframework.web.client.RestTemplate
import javax.annotation.Resource


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 10/24/22
 * @Software: IntelliJ IDEA
 */
@RestController
@RequestMapping("/nacos")
@CrossOrigin

class NacosController {
    @Resource
    private lateinit var restTemplate: RestTemplate

    @RequestMapping("/OK")
    fun OK(): ResultData {
        val data = ResultInfo.setData("SAdaszds")
        println(data.toString())
        return data
    }

    @RequestMapping(value = ["/echo"])
    fun echo(): ResultData {
        return ResultInfo.setData(
            restTemplate.getForObject<ResultData>(
                Constant.Flower + "/flower/selectAll",
                ResultData::class.java
            ) as ResultData
        )
    }
}